package com.jdrx.factory;

import com.jdrx.beans.enums.EApiStatus;
import com.jdrx.beans.vo.ResponseVO;

/**
 * 消息生产工厂类
 */
public class ResponseFactory {

	/**
	 * 正常消息
	 */
	public static ResponseVO ok(Object obj) {
		ResponseVO vo = new ResponseVO();
		vo.setData(obj);
		vo.setMessage(EApiStatus.SUCCESS.getMessage());
		vo.setStatus(EApiStatus.SUCCESS.getStatus());
		return vo;
	}

	/**
	 * 错误消息
	 *
	 * @param obj    消息体data
	 * @param status 状态关联 EApiStatus
	 */
	public static ResponseVO err(Object obj, EApiStatus status) {
		ResponseVO vo = new ResponseVO();
		vo.setData("");
		vo.setMessage(String.valueOf(obj));
		vo.setStatus(status.getStatus());
		return vo;
	}

	/**
	 * 错误消息的返回
	 * 
	 * @param msg    提示的消息
	 * @param status 错误的状态码
	 * @return 返回ResposeVO
	 */
	public static ResponseVO err(String msg, String status) {
		ResponseVO vo = new ResponseVO();
		vo.setData("");
		vo.setMessage(msg);
		vo.setStatus(status);
		return vo;
	}
}